package com.alan.camunda.boot.service;


import com.alan.camunda.boot.util.BpmnUtil;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.model.bpmn.instance.FlowElement;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("callProcessVersionJudge")
public class CallProcessVersionJudge {


    public Integer judge(DelegateExecution execution) {
        FlowElement bmei = execution.getBpmnModelElementInstance();
        Map<String, String> allExtensionProperties = BpmnUtil.getAllExtensionProperties(bmei);
        allExtensionProperties.entrySet().forEach(e -> {
            System.out.println(e.getKey() + " : " + e.getValue());
        });
        return 1;
    }

    /**
     * 判断启动哪个版本的流程
     * @param flowId
     * @param defaultVersion
     * @param versionId
     * @return
     */
    public Integer judgeVersion(String flowId, Boolean defaultVersion, Integer versionId) {
        // flow_id, boolean default, version_id
        System.out.println("flowId:" + flowId);
        System.out.println("defaultVersion:" + defaultVersion);
        System.out.println("versionId:" + versionId);

        return 1;
    }


}
